using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Drawing;

namespace XsltHelper
{


	/// <summary>
	/// Contains coordinates of the carret for the XmlRichTextBox control.
	/// </summary>
	public struct CharPoint
	{

		public int Line {
			get { return _line; }
			set { _line = value; }
		}
		private int _line;

		public int Column {
			get { return _column; }
			set { _column = value; }
		}
		private int _column;

		public int AbsolutePosition {
			get { return _absolutePosition; }
			set { _absolutePosition = value; }
		}
		private int _absolutePosition;


		public static readonly CharPoint Empty;

		static CharPoint() {
			CharPoint.Empty = new CharPoint();
		}

		public CharPoint(int l, int c, int a) {
			this._line = l;
			this._column = c;
			this._absolutePosition = a;
		}

		public override string ToString() {
			return (String.Format("{{L={0}, C={1}}}", this._line, this._column));
		}

	}

	public static class Win32
	{
		[DllImport("user32")]
		public static extern IntPtr SendMessage(HandleRef hWnd, int msg,
					int wParam, int lParam);

		[DllImport("user32")]
		public static extern int GetCaretPos(ref Point lpPoint);

		[DllImport("User32.dll", CharSet = CharSet.Auto)]
		public static extern IntPtr SendMessage(IntPtr h,
		 int msg,
		 int wParam,
		 int[] lParam);

		public const int EM_LINEINDEX = 0xbb;
		public const int EM_LINEFROMCHAR = 0xc9;
		public const int EM_GETSEL = 0xb0;
		public const int EM_SETTABSTOPS = 0x00CB;

	}

}
